﻿using Sumc.Client.ModernUI.Common;
using Sumc.Models.Responses;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Sumc.Client.ModernUI.Services
{
    public class SessionRepository : BaseRepository, ISessionRepository
    {
        public SessionRepository()
        {
            this.expireTime = this.zeroTimeSpan;
        }

        public async Task<AuthForm> GetCaptchaCode()
        {
            var url = string.Format("{0}Sessions", Constants.BaseSumcApiUrl);
            var authForm = await this.Get<AuthForm>(url);
            return authForm;
        }

        public async Task<bool> PostCaptchaCode(string token, string code)
        {
            var url = string.Format("{0}Sessions/Authenticate?token={1}&code={2}",
                Constants.BaseSumcApiUrl, token, code);
            var emptyList = new List<KeyValuePair<string, string>>()
            {
                new KeyValuePair<string, string>(string.Empty,string.Empty)
            };
            var response = await this.Post<bool>(url, emptyList);
            return response;
        }
    }
}
